package com.tensquare.user.interceptor;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurationSupport;

@Configuration
public class InterceptorConfig extends WebMvcConfigurationSupport {

    @Autowired
    private JwtInterceptor jwtInterceptor;

    @Override
    protected void addInterceptors(InterceptorRegistry registry) {
        // 注册拦截器要声明拦截器对象和要拦截的路径
        registry.addInterceptor(jwtInterceptor)/*拦截器对象*/
                .addPathPatterns("/**")/*拦截的路径*/
                .excludePathPatterns("/**/login/**");/*放行的路径*/
    }
}
